Transactions
The PersistenceManager class has three static methods to manage transactions.
You can start a new transaction with
PersistenceManager.StartTransaction(IsolationLevel.ReadCommitted); |
As a parameter define the IsolationLevel of the transaction. This enumeration is part of the System.Data namespace.
You can commit a running transaction with
PersistenceManager.CommitTransaction(); |
You can abort a running transaction with
PersistenceManager.RollbackTransaction(); |
So if you want to create two new Employees in a transaction, you can use
PersistenceManager.StartTransaction(IsolationLevel.ReadCommitted); Employee e1 = new Employee("Duck", "Donald"); e1.Persist(); Employee e2 = new Employee("Duck", "Daisy"); e2.Persist(); PersistenceManager.CommitTransaction(); |